import MathUtil from '@/MathUtil';
import MovementCommon from 'code/Core/Common/MovementCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 *  狙击
 **/
export default class YX_SniperAttack extends AbilityBase {
    static instance: YX_SniperAttack;
    constructor(id: string = 'Ajj1') {
        super(id);
        YX_SniperAttack.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        MovementCommon.LineMissile({
            speed: 1200,
            missile: 'SpiritArrow_ByEpsilon\\SpiritArrow_ByEpsilon.mdx',
            caster: source,
            angle: MathUtil.angleBetweenCoords(GetUnitX(source), GetUnitY(source), tarX, tarY),
            distance: 1800,
            radius: 75,
            onHit: this.onMissileHit.bind(this),
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    onMissileHit(p: LineMissileConfig, hitBody: unit) {
        let lv = this.getAbilityLevel(p.caster);
        let dmg = 250 * lv + UnitCommon.取攻击(p.caster) * (0.5 + 0.5 * lv);
        DamageSystemInstance.applyAttackDamage(hitBody, p.caster, dmg, this.id);
    }
}
